package com.tianyang.yukuaifuzs.business.main.adapter;

import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tianyang.yukuaifuzs.R;
import com.tianyang.yukuaifuzs.business.main.bean.PosAgentOutput;
import com.tianyang.yukuaifuzs.module.roundview.RoundTextView;
import com.tianyang.yukuaifuzs.utils.VerifyUtil;

import java.util.ArrayList;

/**
 * Description：服务商管理
 * Created by xyj on 2024/3/10
 */
public class ServiceManageAdapter extends BaseQuickAdapter<PosAgentOutput, BaseViewHolder> {

    public ServiceManageAdapter() {
        super(R.layout.item_service_manage, new ArrayList<>());
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, PosAgentOutput item) {
        if (item != null) {
            helper.setText(R.id.createTimeTv, VerifyUtil.checkString(item.getCreateDate()))
                    .setText(R.id.nameTv, item.getName())
                    .setText(R.id.phoneTv, item.getPhone());
            RelativeLayout bottomRl = helper.getView(R.id.bottomRl);
            TextView isAuthTv = helper.getView(R.id.isAuthTv);
            RoundTextView updateTypeRtv = helper.getView(R.id.updateTypeRtv);
            if (item.getStatus() >= 1) {
                bottomRl.setVisibility(View.VISIBLE);
                isAuthTv.setText("已认证");
                isAuthTv.setBackgroundResource(R.drawable.img_auth_status_check);
                updateTypeRtv.getDelegate().setStrokeColor(ContextCompat.getColor(mContext, R.color.color_base));
                updateTypeRtv.setTextColor(ContextCompat.getColor(mContext, R.color.color_base));
            } else {
                bottomRl.setVisibility(View.GONE);
                isAuthTv.setText("未认证");
                isAuthTv.setBackgroundResource(R.drawable.img_auth_status_normal);
                updateTypeRtv.getDelegate().setStrokeColor(ContextCompat.getColor(mContext, R.color.color_base));
                updateTypeRtv.setTextColor(ContextCompat.getColor(mContext, R.color.color_base));
            }
            helper.addOnClickListener(R.id.updateTypeRtv);
        }
    }
}
